//==================================================================
//  Copyright (C) 2006-2007  Davide Pasca
//
//  This library is free software; you can redistribute it and/or
//  modify it under the terms of the GNU Lesser General Public
//  License as published by the Free Software Foundation; either
//  version 2.1 of the License, or (at your option) any later version.
//
//  This library is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
//  Lesser General Public License for more details.
//
//  You should have received a copy of the GNU Lesser General Public
//  License along with this library; if not, write to the Free Software
//  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
//==================================================================
///
///
///
///
//==================================================================

#include "stdafx.h"

//==================================================================
namespace GXY {

//==================================================================
SystemState::SystemState( int disp_w, int disp_h, float disp_aspect )
{
	_disp_w = disp_w;
	_disp_h = disp_h;
	_disp_aspect = disp_aspect;

	_sca_x = 1.0f;					// 1.0 (normal size)
	_sca_y = 1.0f;					// 1.0 (normal size)

	_blend = PSYSGFX::BASICBLEND_TRANSPARENT;
	_global_alpha_coe = 256;

	_rot_z = 0;
	_rot_z_cos = 1;
	_rot_z_sin = 0;

	_font_idx		= 0;			// font type 0
	_font_is_prop	= 1;			// font is proportional
	_font_sca_x = 1.0f;
	_font_sca_y = 1.0f;

	for (int i=0; i < 4; ++i)
		for (int j=0; j < 4; ++j)
			_colverts[i][j] = 255;

	_cur_proj_m.Identity();
	_cur_mview_m.Identity();
}

//============================================================================
void SystemState::SetViewport( float x, float y, float w, float h )
{
	_viewport[0] = x;
	_viewport[1] = y;
	_viewport[2] = w;
	_viewport[3] = h;

	_global_sca[0] = _disp_w / (float)w;
	_global_sca[1] = _disp_h / (float)h;
	_global_off[0] = _disp_w * 0.5f;
	_global_off[1] = _disp_h * 0.5f;
}

//============================================================================
void SystemState::SetFontScale( float sca_x, float sca_y )
{
	_font_sca_x = sca_x;
	_font_sca_y = sca_y;
}

//============================================================================
Context::Context( RendDevice *rdevicep, int disp_w, int disp_h, float disp_aspect ) :
	_rdevicep(rdevicep),
	_sys_state(disp_w, disp_h, disp_aspect),
	_n_col_verts(0),
	_n_tex_verts(0),
	_cur_texturep(NULL),
	_cur_blendtype(PSYSGFX::BASICBLEND_OPAQUE),
	_has_texture(false),
	_n_lists(0),
	_listp(NULL)
{
	_cur_tex[0] = 0;
	_cur_tex[1] = 0;

	_glt_cur_col[0] = 255;
	_glt_cur_col[1] = 255;
	_glt_cur_col[2] = 255;
	_glt_cur_col[3] = 255;

	_mload_si = NULL;
	for (int i=0; i < GXY_MAX_FONTS; ++i)
		_font_use_table[i] = 0;
}


};
